﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Idte.Common.ArtifactModel;
using Idte.Common.Patterns;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;

namespace Idte.Common.Process
{

    public interface IStep : INamed, IComponent
    {
        IExecutionContext Execute(IExecutionContext context);
        StepDescriptor Descriptor { get;  }
    }
    //public abstract class Step : Step<IProcessDescriptor>
    //{
    //    protected Step(StepDescriptor<IProcessDescriptor> descriptor) : base(descriptor) { }
    //}
    public abstract class Step : INamed, IComponent
    {
        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public Guid Id { get; set; }
        protected Step(StepDescriptor descriptor)
        {
            this.Descriptor = descriptor;
        }

        public StepDescriptor Descriptor { get; protected set; }

        public abstract IExecutionContext Execute(IExecutionContext context);
        //{
        //    //return context.Execute(this);
        //    // TODO: Implement execution code here
        //    throw new NotImplementedException();
        //}

        public virtual string Name
        {
            get { return Descriptor.Name;  }
        }

        public virtual int? Sequence { get; set; }

        public string Code
        {
            get { return Descriptor.Code; }
        }
    }
}
